package day0521;

import java.util.Arrays;
import java.util.Scanner;

public class Test9 {
    public static void main(String[] args) {
        int[]  a =  {1,5,3,2,7,7,3};
        //1.调用inputEle()输入元素
        sort(a);
        System.out.println(Arrays.toString(a));
    }

    public static void sort(int[] a) {
        for (int i = 1; i < a.length; i++) {
            for (int j = 0; j < a.length-i; j++) {
                if(a[j] > a[j+1]){
                    int t=a[j];
                    a[j]=a[j+1];
                    a[j+1]=t;
                }
            }
        }
    }


    //inputEle()方法给a数组中输入元素
    //让此方法返回输入好元素的数组
    private static void inputEle(int[] a2) {
        Scanner s=new Scanner(System.in);
        for (int i = 0; i < a2.length; i++) {
            a2[i]=s.nextInt();
        }
        System.out.println(Arrays.toString(a2));
    }

    private static int search(int[] a, int num) {
        int left=0;
        int right=a.length-1;
        int mid= (left + right) / 2;
        while(true){//循环内：用要查找的元素num和mid比较看是否相等，如果相等就找到了(结果就是mid)
            //如果
            if(a[mid]>num){
                right=mid-1;//修改right的值为mid-1
                mid= (left + right) / 2;
            }else if(a[mid]==num){
                //用return 结果 传回到main方法中
                return  mid;//break;//就结束循环
            }else if(a[mid]<num){
                left=mid+1;//修改left的值为mid+1
                mid= (left + right) / 2;
            }
        }
    }





}
